#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

void pai(int* arr, int n) {
    for (int i = 0; i < n - 1; i++) {
        for (int j = 0; j < n - 1 - i; j++) {
            if (arr[j] > arr[j + 1]) {
                int t = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = t;
            }
        }
    }
}
int main() {
    int numsSize;
    scanf("%d", &numsSize);
    int arr[numsSize];
    for (int i = 0; i < numsSize; i++) {
        scanf("%d", &arr[i]);
    }
    pai(arr, numsSize);
    int k;
    scanf("%d", &k);
    for (int i = 0; i < k; i++) {
        printf("%d ", arr[i]);
    }
    return 0;
}